package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import so.cuo.platform.mmedia.Mmedia;
	import so.cuo.platform.mmedia.MmediaEvent;

	public class EventDemo extends Sprite
	{
		public var fullApid:String="";
		var mmedia:Mmedia= Mmedia.getInstance();

		public function EventDemo()
		{
			super();
			if (mmedia.supportDevice)
			{
				mmedia.setInterstitialKeys(fullApid);
				mmedia.addEventListener(MmediaEvent.onBannerFailedReceive, onAdReceived);
				mmedia.addEventListener(MmediaEvent.onBannerReceive, onAdReceived);
			}
			stage.addEventListener(MouseEvent.CLICK, clickStage);
		}

		protected function clickStage(event:MouseEvent):void
		{
			mmedia.showBannerAbsolute(Mmedia.IAB_BANNER, 0, 10);
			if (mmedia.isInterstitialReady())
			{
				mmedia.showInterstitial();
			}
			else
			{
				mmedia.cacheInterstitial();
			}
		}

		protected function onAdReceived(event:MmediaEvent):void
		{
			trace(event.type, event.data);
		}
	}
}
